<template>
	<view>
		<wrapBgImg bgImg="mine/mine_top_bg.png" />

		<view class="wrap flex column" :style="'padding-top:' + navigationHeight + 'px;'">
			<userInfo :userInfo="dataInfo" />

			<walletInfo :userInfo="redBagInfo" />

			<orderInfo />

			<articleInfo />

			<cooperationInfo :userInfo="dataInfo" />

			<serviceInfo :userInfo="dataInfo" />
		</view>
	</view>
</template>

<script>
	import { getUserInfo } from "@/API/mine.js";
	import wrapBgImg from "@/components/navigationBar/bgImg.vue";
	import userInfo from "@/components/mine/userInfo.vue";
	import walletInfo from "@/components/mine/walletInfo.vue";
	import orderInfo from "@/components/mine/orderInfo.vue";
	import articleInfo from "@/components/mine/articleInfo.vue";
	import cooperationInfo from "@/components/mine/cooperationInfo.vue";
	import serviceInfo from "@/components/mine/serviceInfo.vue";
	export default {
		components: {
			wrapBgImg,
			userInfo,
			walletInfo,
			orderInfo,
			articleInfo,
			cooperationInfo,
			serviceInfo,
		},
		data() {
			return {
				loginStatus: false, //登录状态
				navigationHeight: this.$navigationHeight,
				dataInfo: null, //用户信息
				redBagInfo: null, //红包信息
			};
		},
		onShow() {
			this.loginStatus = this.$filters.loginStatus();
			if (this.loginStatus === true) {
				this.getData();
			} else {
				this.dataInfo = null;
				this.redBagInfo = null;
			}
		},
		methods: {
			/**
			 * 网络请求
			 */
			getData() {
				getUserInfo().then((res) => {
					this.dataInfo = res.data.userinfo;
					this.redBagInfo = {
						coupon_count: res.data.statistics.dynamic.coupon,
						red_packet_count: res.data.userinfo.bribe,
						collect_count: res.data.statistics.dynamic.collection,
						balance: res.data.userinfo.balance,
						concern: res.data.statistics.dynamic.concern,
						total_money: res.data.userinfo.total_money,
					};
					this.$store.commit('user/setUserInfo', this.dataInfo);
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.wrap {
		padding: 20rpx;
		box-sizing: border-box;
		gap: 15rpx;
	}
</style>
